package com.example.demo.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.Entity.Directoryitem;
import com.example.demo.Entity.Note;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DirectoryitemMapper extends BaseMapper<Directoryitem>{
    @Select("select * from directoryitem where user_id =#{userId}")
    public List<Directoryitem> findDirectoryitemByUserId(int userId);

   @Select("select * from Note where note_id in " +
           "( select note_id from directory,directoryitem " +
           "where directory.directory_group=directoryitem.directory_id " +
           "and directory_id=#{directoryId})")
    public List<Note> findNoteByDirectoryId(int directoryId);

   @Delete("delete  from directoryitem where directory_id= #{directoryId}")
    public void deleteByDirectoryId(int directoryId);

   @Select("select * from directoryitem where directory_id= #{directoryId}")
    public Directoryitem selectByDirectoryId(int directoryId);


    @Select("select * from directoryitem where directory_name= #{directoryName}")
    public Directoryitem selectByDirectoryName(String directoryName);
}
